var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var EventManager = require("AA_EventManager");
var ResKeeper = require("AA_ResKeeper");
var EvenType = require("AA_EvenType");
var Excel = require("AA_Excel");
var GameGlobalVariable = require("AA_GameGlobalVariable");
var BuffMag = require("AA_BuffMag");
var UI_MosterLogic = require("AA_UI_MosterLogic");
var UI_Bullet = require("AA_UI_Bullet");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
_decorator.property;

var _def_UI_BulletCollider = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.offtime = 0;
    t.isbao = false;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onCollisionEnter = function (e, t) {
    if (new Date().getTime() - this.offtime >= 50) {
      this.offtime = new Date().getTime();
      var o = t.node.parent.getComponent(UI_Bullet.default);
      o.hideBullet();
      var n = e.node.getComponent(UI_MosterLogic.default);
      var i = Excel.Excel.shuiguobuff(o.attackfang.sgtianfuid);
      var a = -1;
      i && (a = i.buffefftype);
      switch (a) {
        case 4:
          GameGlobalVariable.GameGlobalVariable.playHitBomb2();
          var r = i.value[0];
          r += r * BuffMag.BuffMgr.getBombBuffScope(o.attackfang);
          var s = o.getNowMosterNode(r);
          EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Add_BaoZha, o.node.getPosition(), 3, r);
          n.beAttack(o, true);
          s.forEach(function (e) {
            var t = e.getComponent(UI_MosterLogic.default);
            if (t.node.uuid != n.node.uuid) {
              BuffMag.BuffMgr.mosterBeHit(t, o.attackfang);
              var a = o.getBulletAttack(n) * i.value[1] / 100;
              t.fujiaAttack(a, 1, o);
              BuffMag.BuffMgr.getMosterBombZengShang() > 0 && t.setIsXiGuaBomb();
            }
          });
          break;
        default:
          BuffMag.BuffMgr.mosterBeHit(n, o.attackfang);
          n.beAttack(o);
          if (this.isbao) {
            GameGlobalVariable.GameGlobalVariable.playHitBomb2();
          } else {
            GameGlobalVariable.GameGlobalVariable.playHit();
          }
      }
    }
  };
  _creator.prototype.onYouHuaPeng = function (e) {
    if (new Date().getTime() - this.offtime >= 50) {
      this.offtime = new Date().getTime();
      var t = this.node.parent.getComponent(UI_Bullet.default);
      t.hideBullet();
      var o = e.getComponent(UI_MosterLogic.default);
      var n = Excel.Excel.shuiguobuff(t.attackfang.sgtianfuid);
      var i = -1;
      n && (i = n.buffefftype);
      switch (i) {
        case 4:
          GameGlobalVariable.GameGlobalVariable.playHitBomb2();
          var a = n.value[0];
          a += a * BuffMag.BuffMgr.getBombBuffScope(t.attackfang);
          var r = t.getNowMosterNode(a);
          EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Add_BaoZha, t.node.getPosition(), 3, a);
          o.beAttack(t, true);
          r.forEach(function (e) {
            var i = e.getComponent(UI_MosterLogic.default);
            if (i.node.uuid != o.node.uuid) {
              BuffMag.BuffMgr.mosterBeHit(i, t.attackfang);
              var a = t.getBulletAttack(o) * n.value[1] / 100;
              i.fujiaAttack(a, 1, t);
              BuffMag.BuffMgr.getMosterBombZengShang() > 0 && i.setIsXiGuaBomb();
            }
          });
          break;
        default:
          BuffMag.BuffMgr.mosterBeHit(o, t.attackfang);
          o.beAttack(t);
          this.quanTiDongShangHai(t, o);
          this.fujiaShangHai(t, o);
          this.fanweiShangHai(t, o);
          if (this.isbao) {
            GameGlobalVariable.GameGlobalVariable.playHitBomb2();
          } else {
            GameGlobalVariable.GameGlobalVariable.playHit();
          }
          this.backSatrt(t, o);
      }
    }
  };
  _creator.prototype.backSatrt = function (e, t) {
    if (16 == e.attackfang.playerId) {
      var o = BuffMag.BuffMgr.getBackBuff(e.attackfang.playerId + 1e3);
      if (o) {
        var n = o.probability / 100;
        Math.random() <= n && (-1 != Excel.Excel.shuiguoguaiwu(t.mosterId).boss || t.overback || t.backStart());
      }
    }
  };
  _creator.prototype.quanTiDongShangHai = function (e) {
    if (14 == e.attackfang.playerId && 4 == e.attackfang.playerInfo.equipLevel) {
      var t = Excel.Excel.shuiguobuff(85);
      var o = t.probability / 100;
      if (Math.random() <= o) {
        var n = t.value[0];
        var i = e.getNowMosterNode(n);
        var a = [];
        for (var r = 0; r < i.length; r++) {
          var s = i[r];
          s.getComponent(UI_MosterLogic.default).fanweidong || a.push(s);
        }
        a.length > 0 && EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Add_FanWeiBaoZha, e.node.getPosition(), a, e.attackfang, e.attack);
      }
    }
  };
  _creator.prototype.binDongEwai = function () {};
  _creator.prototype.fanweiShangHai = function (e, t) {
    this.isbao = false;
    var o = BuffMag.BuffMgr.getFanweiBuff(e.attackfang);
    if (o && (12 != e.attackfang.playerId && (this.isbao = true), Math.random() < o.probability / 100)) {
      var n = e.attack * o.value[0] / 100;
      var i = o.value[1];
      e.getNowMosterNode(i).forEach(function (i) {
        var a = i.getComponent(UI_MosterLogic.default);
        if (t.node.uuid != a.node.uuid) {
          a.fujiaAttack(n, 5, e);
          a.setJianShu(o.value[2], o.bufftime, e.attackfang);
        }
      });
    }
  };
  _creator.prototype.fujiaShangHai = function (e, t) {
    var o = BuffMag.BuffMgr.getBombBuff(e.attackfang);
    this.isbao = false;
    if (o) {
      this.isbao = true;
      var n = e.attack * o.value[1] / 100;
      var i = o.value[0];
      e.getNowMosterNode(i).forEach(function (e) {
        var o = e.getComponent(UI_MosterLogic.default);
        t.node.uuid != o.node.uuid && o.fujiaAttack(n, 5);
      });
      var a = 1;
      5 == e.attackfang.playerId && (a = 3);
      EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Game_Add_BaoZha, e.node.getPosition(), a, i);
    }
  };
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_UI_BulletCollider;